package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 数据字典-客户状态
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/25 21:53
 * @since v1.0
 */
@Getter
public enum CustomerTypeEnum {
    // 客户状态
    POTENTIAL_CUSTOMER("1", "enum.customerType.name.potential_customer", "potentialCustomer"),


    INITIAL_CONTACT("2", "enum.customerType.name.initial_contact", "initialContact"),


    CONTINUOUS_FOLLOW("3", "enum.customerType.name.continuous_follow", "continuousFollow"),


    TRANSACTION_CUSTOMER("4", "enum.customerType.name.transaction_customer", "transactionCustomer"),


    LOYAL_CUSTOMERS("5", "enum.customerType.name.loyal_customers", "loyalCustomers"),


    INVALID_CUSTOMER("6", "enum.customerType.name.invalid_customer", "invalidCustomer"),
    ;
    private String code;
    private String name;
    private String attr;

    CustomerTypeEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public static CustomerTypeEnum getByCode(String code) {
        for (CustomerTypeEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
